package com.aizuda.boot.modules.business.contract.entity.vo;


import com.aizuda.boot.modules.common.constant.enums.DisplayTypeEnum;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Map;

/**
 * @Author sangyirong
 * @ClassName WorkflowFormFieldDTO
 * @Version 1.0
 * @Date 2025/5/22 10:49
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "合同流程表单字段")
public class WorkflowFormFieldDTO {

    @Schema(description = "关联ID")
    private Long id;

    @Schema(description = "字段ID")
    private Long fieldId;

    @Schema(description = "字段在该流程表单中的显示顺序")
    private Integer fieldOrder;

    @Schema(description = "字段提示内容（输入框内的提示文本）")
    private String placeholderText;

    @Schema(description = "字段空状态说明文本")
    private String emptyStateText;

    @Schema(description = "字段是否隐藏")
    private Boolean isHidden;

    @Schema(description = "字段引导说明内容")
    private Map<String, Object> helpContent;

    @Schema(description = "引导说明展示方式：BUBBLE-气泡卡片，BELOW-展示在字段下方")
    private DisplayTypeEnum helpDisplayType;

    @Schema(description = "字段名称")
    private String fieldName;

    @Schema(description = "字段编码")
    private String code;

    @Schema(description = "字段类型")
    private String fieldType;

    @Schema(description = "字段选项（JSON格式存储）")
    private Map<String, Object> fieldOptionsMap;

    @Schema(description = "字段描述")
    private String fieldDescription;

    @Schema(description = "数字类型保留小数位数")
    private Integer decimalPlaces;

    @Schema(description = "数字类型单位")
    private String unit;

    @Schema(description = "选项类型字段的子类型")
    private String optionType;

    @Schema(description = "是否系统字段（1-系统，0-非系统）系统字段不可删除")
    private Boolean isSystem;

    @Schema(description = "是否启用（1-启用，0-禁用）")
    private Boolean isEnabled;

    @Schema(description = "子字段列表")
    private List<WorkflowFormFieldDTO> childFields;

    @Schema(description = "字段配置详情")
    private ConfigDetail configDetails;

    @Schema(description = "是否需要展示")
    private Boolean isShow;


    @Data
    @NoArgsConstructor
    @Schema(description = "字段配置详情")
    public final static class ConfigDetail {

        @Schema(description = "字段是否必填")
        private Boolean isRequired;

        @Schema(description = "字段提示内容")
        private String placeholderText;

        @Schema(description = "字段空状态说明文本")
        private String emptyStateText;

        @Schema(description = "字段默认值")
        private Object defaultValue;


        public Object getDefaultValue() {
            if ("null".equals(defaultValue)) {
                return null;
            }
            return defaultValue;
        }

    }
}
